package main

import (
	"fmt"
	"github.com/gogf/gf/text/gstr"
)

func main() {
	res := MakeNewSalt("yuanlj")
	fmt.Println(res)

	fmt.Println(8^9)
	fmt.Println(ord("a"))
	fmt.Println(chr(97))
}

func MakeNewSalt(salt string) (string) {
	if salt == "" || len(salt) == 0 {
		return ""
	}
	key := "gTx9bi1#NQ7b%yKY"
	uLen := len(salt)
	var res,c string
	for i := 0; i < uLen; i++ {
		for j := 0; j < 16; j++ {
			c = chr(int(salt[i]) ^ int(key[j]))
			res += c
		}
	}
	if len(res) > 16 {
		res = res[0:16]
	}
	res = gstr.TrimRight(res)
	return res
}

func ord(c string) string {
	r := int(c[0])
	res := fmt.Sprintf("%d", r)
	return res
}

func chr(i int) string {
	ch := rune(i)
	res := fmt.Sprintf("%c", ch)
	return res
}
